﻿<div ng-controller="Supplier_SupplierAddC">
    <div class="bg-light lter b-b wrapper-md">
        <h1 class="m-n font-thin h3">钢厂添加</h1>
    </div>
    <div class="wrapper-md">
        <div class="panel panel-default">
            <div class="table-responsive">
                <form name="form" class="form-validation">
                    <div class="panel panel-default">
                        <div class="panel-body">
                            <div class="form-group">
                                <label>钢厂名称（城市+钢厂名，例如：山西建邦）</label>
                                <input ng-model="supplierdata.Name" type="text" class="form-control" required>
                            </div>
                            <div class="form-group">
                                <label>品牌名称</label>
                                <input ng-model="supplierdata.Brand" type="text" class="form-control" required>
                            </div>
                            <div class="form-group">
                                <label>联系人</label>
                                <input ng-model="supplierdata.Contacts" type="text" class="form-control">
                            </div>
                            <div class="form-group">
                                <label>电话</label>
                                <input ng-model="supplierdata.Phone" ng-pattern="/^[1][3-8]\d{9}$/" type="text" class="form-control">
                            </div>
                            <div class="form-group">
                                <label>备注（非必填）</label>
                                <input ng-model="supplierdata.Remark" type="text" class="form-control">
                            </div>
                            <div class="row text-right">
                                <button type="button" ng-disabled="form.$invalid" class="btn btn-success" ng-click="addSupplier()">新建钢厂</button>
                                <button type="button" class="btn btn-default" ng-click="$state.go('app.Supplier_List')">取消</button>
                            </div>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>

<script>
    angular.module('app')//非标优惠
        .controller("Supplier_SupplierAddC", function ($scope, $state, $http, $stateParams) {
       
            $scope.supplierdata = {};
           
//            提交信息
            $scope.addSupplier = function () {
                console.log($scope.supplierdata);
                $http.post('../api/Supplier', $scope.supplierdata)
                        .then(function (res) {
                            if (res.State <= 0) {
                                alert(res.Msg);
                            } else {
                                alert("添加成功");
                                $state.go('app.Supplier_List');
                            }
                            
                        }, function (res) {
                            alert("提交失败");
                        });
            };


        })

</script>